{  Statement: http://acmp.ru/?main=task&id_task=52
   Verdict: Accepted
}
uses
    SysUtils, Math;

var
    n,i:longint;
    a:array[1..6] of byte;

begin
reset(input,'input.txt');
rewrite(output,'output.txt');
read(n);
fillchar(a,sizeof(a),0);
for i:=6 downto 1 do begin 
    a[i] := n mod 10;
    n := n div 10;
end;
if a[1] + a[2] + a[3] = a[4] + a[5] + a[6] then write('YES') else write('NO');
end.